home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / AmigaSystem / Scalos / GuiGFXLib / src / createyuvtab.c next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  988 b   |  57 lines

  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <proto/exec.h>
  5. #include <proto/dos.h>
  6. #include <dos/dos.h>
  7. #include <exec/exec.h>
  8. #include <exec/memory.h>
  9.  
  10. void main (void)
  11. {
  12.     ULONG *colortable;
  13.     if (colortable = AllocVec(sizeof(ULONG) * 6*6*6, MEMF_ANY))
  14.     {
  15.         BPTR fh;
  16.         int y,u,v;
  17.         DOUBLE Y, U, V;
  18.         ULONG *p = colortable;
  19.         
  20.         for (y = 0; y < 6; ++y)
  21.         {
  22.             for (u = 0; u < 6; ++u)
  23.             {
  24.                 for (v = 0; v < 6; ++v)
  25.                 {
  26.                         Y = (255 * y / 5);
  27.                         U = (222 * u / 5) - 111;
  28.                         V = (312 * v / 5) - 156;
  29.                         
  30.                         *p++ =
  31.                                 ((int)(Y + 1.140 * V) << 16) +
  32.                                 ((int)(Y - 0.396 * U - 0.581 * V) << 8) +
  33.                                 (int)(Y + 2.029 * U);
  34.                 }
  35.             }
  36.         }
  37.  
  38.         fh = Open("ram:yuv", MODE_NEWFILE);
  39.         if (fh)
  40.         {
  41.             int l;
  42.             char buf[1000];
  43.             p = colortable;
  44.             for (y = 0; y < 6 * 6; ++y)
  45.             {
  46.                 sprintf(buf, "    0x%lx,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx,\n", p[0],p[1],p[2],p[3],p[4],p[5]);
  47.                 l = strlen(buf);                
  48.                 p += 6;
  49.                 Write(fh, buf, l);
  50.             }
  51.         
  52.             Close(fh);
  53.         }
  54.     }
  55. }
  56.  
  57.